why_cant_you_take_inputs_while_printing_in_pycharm_it_is_so_annoying = [[input() for i in range(int(input()))] for _ in range(int(input()))]
for words in why_cant_you_take_inputs_while_printing_in_pycharm_it_is_so_annoying:
maxes = []
for letter in 'abcde':
vals = sorted([2 * i.count(letter) - len(i) for i in words])[::-1]
pi = ''
storyL = 0
storyB = 0
for i in vals:
if storyB + i > 0:
storyB += i
storyL += 1
maxes.append(storyL)
print(max(maxes))
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> oset;
#define int long long
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef queue<int> qi;
typedef set<int> si;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef priority_queue<int,std::vector<int>,greater<int>> min_prior;
typedef priority_queue<int> prior;
#define fori(i,n) for(int i = 0; i < n; i++)
#define rfori(i,n) for(int i = n; i >=0; i--)
#define fora(i,a,b) for(int i = a; i <= b; i++)
#define rfora(i,a,b) for(int i = a; i >= b; i--)
#define each(a,x) for(auto a: x)
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define MOD 1000000007
#define MOD1 998244353
#define fill(str,a) memset(str, a, sizeof(str));
#define INF 1e18
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define PI 3.141592653589793238462
#define all(x) (x).begin(), (x).end()
#define pos(v,a) find(all(v),a) - v.begin()
#define sz(v) (int)v.size()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define maxind(v) max_element(all(v)) - v.begin()
#define minind(v) min_element(all(v)) - v.begin()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define int_max 2147483647
#define int_min -2147483647
#define isthere(v,n) (find(all(v),n)!=v.end())
#define delv(v,n) v.erase(find(all(v),n))
#ifndef ONLINE_JUDGE
#include "judge.h"
#else
#define dbg(x)
void init(void){}
#endif
int val(char cot, std::vector<string>& s){
vi v;
for(string temp: s){
vi vun(5,0);
for(char c: temp){vun[c-'a']++;}
v.push_back(vun[cot-'a'] - sz(temp) + vun[cot-'a']);
}
sortvd(v);
int ans = 0,sum = 0;
for(int i: v){
if(sum + i > 0){sum+=i;ans++;}
else{break;}
}
return ans;
}
void fun(){
int n;string temp;std::cin >> n;
std::vector<string> s;
fori(i,n){
std::cin >> temp;
s.push_back(temp);
}
int ans = 0;
for (int i = 0; i < 5; ++i){
ans = max(ans,val( (char)(i + 'a'),s));
}
std::cout << ans << "\n";
}
int32_t main(){
ios:: sync_with_stdio(0),cin.tie(0);cout<<fixed<<setprecision(20);init();int t = 1;
std::cin >> t;
while(t--)
fun();
return 0;
}
/*
*/
566. Reshape the Matrix | 167. Two Sum II - Input array is sorted |
387. First Unique Character in a String | 383. Ransom Note |
242. Valid Anagram | 141. Linked List Cycle |
21. Merge Two Sorted Lists | 203. Remove Linked List Elements |
733. Flood Fill | 206. Reverse Linked List |
83. Remove Duplicates from Sorted List | 116. Populating Next Right Pointers in Each Node |
145. Binary Tree Postorder Traversal | 94. Binary Tree Inorder Traversal |
101. Symmetric Tree | 77. Combinations |
46. Permutations | 226. Invert Binary Tree |
112. Path Sum | 1556A - A Variety of Operations |
136. Single Number | 169. Majority Element |
119. Pascal's Triangle II | 409. Longest Palindrome |
1574A - Regular Bracket Sequences | 1574B - Combinatorics Homework |
1567A - Domino Disaster | 1593A - Elections |
1607A - Linear Keyboard | EQUALCOIN Equal Coins |